﻿package plugin.unionChat.game
{
    import __AS3__.vec.*;
    import cmd.*;
    import com.core.*;
    import com.core.utils.*;
    import com.sh.game.consts.*;
    import com.sh.game.global.*;
    import com.sh.game.net.*;
    import com.sh.game.util.*;
    import consts.*;
    import flash.events.*;
    import flash.external.*;
    import flash.filters.*;
    import flash.geom.*;
    import flash.ui.*;
    import flash.utils.*;
    import manager.*;
    import morn.core.components.*;
    import morn.core.handlers.*;
    import plugin.chatflash.component.*;
    import plugin.chatflash.model.*;
    import plugin.social.*;
    import plugin.union.*;
    import plugin.unionChat.*;
    import pluginfw.*;
    import uiresource.union.*;
    import view.mainUI.*;
    import view.uilt.*;

    public class UnionChatGame extends UnionChatUI
    {
        private var _instance:UnionChat;
        private var _selected:Image;
        private var _menuGame:MenuGame;
        private var _msgDic:Dictionary;
        private var _ShowingTip:Boolean = false;
        private var _sendTime:Number = 0;
        private var _face:FaceGame;
        public var mFilter:DropShadowFilter;
        private var selfMsg:Object;
        private var isChecking:Boolean = false;
        private var _timeID:uint = 0;

        public function UnionChatGame(param1:UnionChat)
        {
            this._msgDic = new Dictionary();
            this.mFilter = new DropShadowFilter(0, 0, 0, 0.8, 2, 2, 10, 1);
            this._instance = param1;
            return;
        }// end function

        override protected function initializeView() : void
        {
            btn_pos.toolTip = "每次求救需花费1000非绑金币";
            this._menuGame = new MenuGame();
            this.addChild(this._menuGame);
            this._menuGame.visible = false;
            ModelProxy.change("data", "unionChatIsInit", true);
            var _loc_1:* = Control.create(UnionChatControl, this);
            ModelProxy.addObserver("chat", _loc_1);
            ModelProxy.addObserver("union", _loc_1);
            var _loc_2:* = ModelProxy.getValue("data", "unionChatMsg");
            if (_loc_2)
            {
                this.doDelayMsg(_loc_2);
            }
            return;
        }// end function

        private function doDelayMsg(param1:Object) : void
        {
            var _loc_2:Vector.<Array> = null;
            var _loc_3:Object = null;
            for each (_loc_3 in param1)
            {
                
                _loc_2 = this.addMsg(_loc_3);
            }
            if (_loc_2)
            {
                this.showMsg(_loc_2);
            }
            return;
        }// end function

        public function initEvent() : void
        {
            btn_close.clickHandler = new Handler(this._instance.close);
            ta_announce.addEventListener(FocusEvent.FOCUS_IN, this.fouseIn);
            ta_announce.addEventListener(FocusEvent.FOCUS_OUT, this.fouseOut);
            ta_announce.addEventListener(MouseEvent.MOUSE_DOWN, this.doStop);
            this.addEventListener(MouseEvent.MOUSE_DOWN, this.fouseNone);
            ta_chat.addEventListener(MouseEvent.MOUSE_DOWN, this.doStop2);
            ta_chat.addEventListener(FocusEvent.FOCUS_IN, this.doCheck);
            ta_chat.addEventListener(FocusEvent.FOCUS_OUT, this.doCheck);
            btn_send.clickHandler = new Handler(this.doSend);
            panel_chat.addEventListener(MouseEvent.MOUSE_DOWN, this.doStop2);
            btn_pos.clickHandler = new Handler(this.sendPos);
            ta_chat.addEventListener(KeyboardEvent.KEY_DOWN, this.chatEnter);
            cb_light.clickHandler = new Handler(this.doCb);
            btn_expression.clickHandler = new Handler(this.doshowFace);
            btn_small.clickHandler = new Handler(this.doSmall);
            return;
        }// end function

        private function doshowFace() : void
        {
            if (this._face)
            {
                this._face.visible = true;
            }
            else
            {
                this._face = new FaceGame(ta_chat);
                this._face.x = btn_expression.x + btn_expression.width;
                this._face.y = btn_expression.y;
                this.addChild(this._face);
            }
            return;
        }// end function

        protected function doCheck(event:FocusEvent) : void
        {
            switch(event.type)
            {
                case FocusEvent.FOCUS_IN:
                {
                    if (ta_chat.text == "请输入聊天内容")
                    {
                        ta_chat.text = "";
                    }
                    break;
                }
                case FocusEvent.FOCUS_OUT:
                {
                    if (ta_chat.text == "")
                    {
                        ta_chat.text = "请输入聊天内容";
                    }
                    break;
                }
                default:
                {
                    break;
                }
            }
            return;
        }// end function

        private function doCb() : void
        {
            ModelProxy.change("data", "isUnionLight", cb_light.selected);
            return;
        }// end function

        public function removeEvent() : void
        {
            btn_close.clickHandler = null;
            ta_announce.removeEventListener(FocusEvent.FOCUS_IN, this.fouseIn);
            ta_announce.removeEventListener(FocusEvent.FOCUS_OUT, this.fouseOut);
            this.removeEventListener(MouseEvent.MOUSE_DOWN, this.fouseNone);
            ta_chat.removeEventListener(MouseEvent.MOUSE_DOWN, this.doStop2);
            list_chater.mouseHandler = null;
            btn_send.clickHandler = null;
            panel_chat.removeEventListener(MouseEvent.MOUSE_DOWN, this.doStop2);
            btn_pos.clickHandler = null;
            ta_chat.removeEventListener(KeyboardEvent.KEY_DOWN, this.chatEnter);
            ta_chat.removeEventListener(FocusEvent.FOCUS_IN, this.doCheck);
            ta_chat.removeEventListener(FocusEvent.FOCUS_OUT, this.doCheck);
            return;
        }// end function

        private function doSmall() : void
        {
            ModelProxy.change("mainui", "addUnionChator", null);
            this._instance.close();
            return;
        }// end function

        protected function chatEnter(event:KeyboardEvent) : void
        {
            event.stopPropagation();
            if (event.keyCode == Keyboard.ENTER)
            {
                this.doSend();
            }
            return;
        }// end function

        private function sendPos() : void
        {
            var _loc_3:Object = null;
            var _loc_4:int = 0;
            var _loc_5:Object = null;
            var _loc_6:Object = null;
            var _loc_7:Array = null;
            var _loc_8:String = null;
            var _loc_1:* = new Date().getTime();
            var _loc_2:* = _loc_1 - this._sendTime;
            if (_loc_2 > 3000)
            {
                _loc_3 = UserData.getUserData();
                if (_loc_3.mapid > 10000)
                {
                    ModelProxy.change("movetips", "error", "抱歉，这个场景不能够使用行会求救功能！");
                    return;
                }
                _loc_4 = UserData.getBagData("gold");
                if (_loc_4 < 1000)
                {
                    WarningManager.show(40);
                    return;
                }
                _loc_5 = ConfigDictionary.data.maplist;
                _loc_6 = _loc_5[_loc_3.mapid];
                _loc_7 = [_loc_3.rid, _loc_3.name, _loc_3.vip, 0, "", 0, _loc_3.unionid, "", _loc_3.sex, _loc_3.career, _loc_3.title, "", 320 + "," + _loc_3.x + "," + _loc_3.y + "," + _loc_3.stageid];
                _loc_8 = _loc_7.join("#!");
                Server.instance.send(110, ChatCMD.ChannelUnion, [2, _loc_8], 0, ConnectType.SYSTEM);
                this._sendTime = _loc_1;
            }
            else
            {
                ModelProxy.change("movetips", "error", "还需" + int((3000 - _loc_2) / 1000 + 1) + "秒才能再次发送信息");
            }
            return;
        }// end function

        protected function doStop2(event:MouseEvent) : void
        {
            event.stopPropagation();
            this._menuGame.visible = false;
            if (this._face)
            {
                this._face.visible = false;
            }
            return;
        }// end function

        private function doSend() : void
        {
            var _loc_5:Array = null;
            var _loc_6:String = null;
            var _loc_7:StringTrie = null;
            var _loc_1:* = ta_chat.text;
            if (_loc_1 == "" || _loc_1 == "请输入聊天内容")
            {
                ta_chat.text = "请输入聊天内容";
                GlobalLayer.instance.root.focus = null;
                return;
            }
            var _loc_2:* = UserData.getUserData();
            if (_loc_2.unionid == 0)
            {
                ModelProxy.change("movetips", "error", "亲，您已不在该行会无法发送信息！");
                return;
            }
            var _loc_3:* = new Date().getTime();
            var _loc_4:* = _loc_3 - this._sendTime;
            if (_loc_3 - this._sendTime > 3000)
            {
                _loc_5 = [_loc_2.rid, _loc_2.name, _loc_2.vip, 0, "", 0, _loc_2.unionid, _loc_1, _loc_2.sex, _loc_2.career, _loc_2.title];
                _loc_6 = _loc_5.join("#!");
                _loc_7 = ModelProxy.getValue("data", "configs1.banednames");
                if (_loc_7)
                {
                    _loc_6 = _loc_7.replaceAll(_loc_6);
                }
                Server.instance.send(110, ChatCMD.ChannelUnion, _loc_6, 0, ConnectType.SYSTEM);
                ta_chat.text = "";
                this._sendTime = _loc_3;
            }
            else
            {
                ModelProxy.change("movetips", "error", "还需" + int((3000 - _loc_4) / 1000 + 1) + "秒才能再次发送信息");
            }
            return;
        }// end function

        public function updateMsg(param1:int, param2:Object) : void
        {
            var _loc_3:Vector.<Array> = null;
            switch(param1)
            {
                case 1:
                {
                    if (param2.cmd == ChatCMD.ChannelUnion)
                    {
                        _loc_3 = this.addMsg(param2);
                        if (this.visible == true)
                        {
                            if (_loc_3)
                            {
                                this.showMsg(_loc_3);
                            }
                        }
                    }
                    break;
                }
                case 2:
                {
                    ta_announce.text = param2.notice;
                    break;
                }
                case 3:
                {
                    this.memberRefresh(ModelProxy.getValue("data", "unionInfo"));
                    break;
                }
                default:
                {
                    break;
                }
            }
            return;
        }// end function

        public function addMsg(param1:Object) : Vector.<Array>
        {
            var _loc_11:String = null;
            var _loc_13:String = null;
            var _loc_14:Vector.<Array> = null;
            var _loc_15:Array = null;
            var _loc_16:RichTextField = null;
            var _loc_17:Array = null;
            var _loc_18:Object = null;
            var _loc_19:Array = null;
            var _loc_20:Object = null;
            var _loc_21:Array = null;
            var _loc_22:String = null;
            var _loc_23:Object = null;
            var _loc_24:Array = null;
            var _loc_25:int = 0;
            var _loc_26:int = 0;
            var _loc_27:int = 0;
            var _loc_28:Object = null;
            var _loc_29:String = null;
            var _loc_2:* = param1.msg.split("#!");
            var _loc_3:* = new ChatVO();
            _loc_3.Type = param1.cmd;
            _loc_3.RoleID = _loc_2[0];
            _loc_3.RoleName = _loc_2[1];
            _loc_3.RoleVip = _loc_2[2];
            _loc_3.ToRoleID = _loc_2[3];
            _loc_3.ToRoleName = _loc_2[4];
            _loc_3.TeamID = _loc_2[5];
            _loc_3.UnionID = _loc_2[6];
            _loc_3.TalkContent = String(_loc_2[7]);
            _loc_3.sex = _loc_2[8];
            _loc_3.career = _loc_2[9];
            _loc_3.title = _loc_2[10];
            _loc_3.itemList = _loc_2[11];
            _loc_3.msgToAnnounce = _loc_2[12];
            if (_loc_2[13])
            {
                _loc_3.isGm = _loc_2[13];
            }
            var _loc_4:* = UserData.getUserData();
            var _loc_5:int = 0;
            var _loc_6:String = "#4fa7db";
            var _loc_7:String = "";
            if (_loc_3.RoleID == _loc_4.rid)
            {
                _loc_6 = "#56b938";
            }
            var _loc_8:* = _loc_3.UnionID;
            if (_loc_3.UnionID == 0)
            {
                _loc_8 = _loc_4.unionid;
            }
            if (_loc_8 == 0)
            {
                return null;
            }
            var _loc_9:* = this._msgDic[_loc_8];
            var _loc_10:* = new Date();
            if (!_loc_9)
            {
                _loc_9 = new Vector.<Array>;
                this._msgDic[_loc_8] = _loc_9;
                for (_loc_13 in this._msgDic)
                {
                    
                    if (int(_loc_13) != _loc_8)
                    {
                        _loc_14 = this._msgDic[_loc_13];
                        while (_loc_14.length > 0)
                        {
                            
                            _loc_15 = _loc_14.shift();
                            _loc_16 = _loc_15[3];
                            if (_loc_16 != null)
                            {
                                _loc_17 = _loc_15[4];
                                if (_loc_17 != null)
                                {
                                    while (_loc_17.length > 0)
                                    {
                                        
                                        _loc_18 = _loc_17.shift();
                                        if (_loc_18.parent)
                                        {
                                            _loc_18.parent.removeChild(_loc_18);
                                        }
                                        if (_loc_18 is Clip)
                                        {
                                            _loc_18.stop();
                                        }
                                        _loc_18 = null;
                                    }
                                    _loc_17 = null;
                                }
                                _loc_16.textfield.removeEventListener(TextEvent.LINK, this.doLink);
                                panel_chat.removeChild(_loc_16);
                                _loc_16.dispose();
                                _loc_16 = null;
                            }
                        }
                        delete this._msgDic[_loc_13];
                    }
                }
            }
            if (_loc_3.msgToAnnounce)
            {
                _loc_19 = _loc_3.msgToAnnounce.split(",");
                _loc_20 = ConfigDictionary.data.announce[_loc_19[0]];
                if (_loc_20 == null)
                {
                    return null;
                }
                _loc_22 = "";
                if (_loc_19[0] == 319)
                {
                    _loc_23 = ConfigDictionary.data.maplist[_loc_19[3]];
                    if (_loc_23 == null)
                    {
                        return null;
                    }
                    _loc_21 = [_loc_23.name, _loc_19[1], _loc_19[2], _loc_19[3]];
                    _loc_22 = StringUtil.substitute(_loc_20.text.replace(/\|""\|/gi, ","), _loc_21);
                }
                else if (_loc_19[0] == 320)
                {
                    _loc_23 = ConfigDictionary.data.maplist[_loc_19[3]];
                    if (_loc_23 == null)
                    {
                        return null;
                    }
                    _loc_21 = [_loc_3.RoleName, _loc_23.name, _loc_19[1], _loc_19[2], _loc_19[3]];
                    _loc_22 = StringUtil.substitute(_loc_20.text.replace(/\|""\|/gi, ","), _loc_21);
                }
                _loc_22 = "<font color=\'" + _loc_6 + "\'>" + _loc_22 + "</font>";
                _loc_11 = _loc_22;
                _loc_3.TalkContent = _loc_22;
            }
            _loc_9.push([true, this.getTitle(_loc_3) + "<font color=\'" + _loc_6 + "\'>" + _loc_3.RoleName + "        " + _loc_10.hours + ":" + (_loc_10.minutes >= 10 ? (_loc_10.minutes) : ("0" + _loc_10.minutes)) + ":" + (_loc_10.seconds >= 10 ? (_loc_10.seconds) : ("0" + _loc_10.seconds)) + "</font>", _loc_3.career + "_" + _loc_3.sex]);
            _loc_11 = "<font color=\'" + (_loc_3.isGm == "gm" ? ("#ff0000") : ("#ffedee")) + "\'>" + _loc_3.TalkContent + "</font>";
            var _loc_12:* = ConfigDictionary.data.item;
            if (_loc_3.itemList)
            {
                _loc_24 = _loc_3.itemList.split(",");
                _loc_24.pop();
                while (_loc_24.length > 0)
                {
                    
                    _loc_25 = _loc_24.shift();
                    _loc_26 = _loc_24.shift();
                    _loc_27 = _loc_24.shift();
                    _loc_28 = _loc_12[_loc_26];
                    if (_loc_28 != null)
                    {
                        if (_loc_25 == 1)
                        {
                            _loc_29 = "<font color=\'" + MColor.getqualitycolor(_loc_28.quality) + "\'><u>[<a href=\'event:item," + _loc_25 + "," + _loc_27 + "\'>" + _loc_28.name + "</a>]</u></font>";
                        }
                        else
                        {
                            _loc_29 = "<font color=\'" + MColor.getqualitycolor(_loc_28.quality) + "\'><u>[<a href=\'event:item," + _loc_25 + "," + _loc_26 + "\'>" + _loc_28.name + "</a>]</u></font>";
                        }
                        _loc_11 = _loc_11.replace("[" + _loc_28.name + "]", _loc_29);
                    }
                }
            }
            _loc_9.push([false, _loc_3.TalkContent, _loc_11]);
            while (_loc_9.length > 60)
            {
                
                _loc_15 = _loc_9.shift();
                _loc_16 = _loc_15[3];
                if (_loc_16 != null)
                {
                    _loc_17 = _loc_15[4];
                    if (_loc_17 != null)
                    {
                        while (_loc_17.length > 0)
                        {
                            
                            _loc_18 = _loc_17.shift();
                            if (_loc_18.parent)
                            {
                                _loc_18.parent.removeChild(_loc_18);
                            }
                            if (_loc_18 is Clip)
                            {
                                _loc_18.stop();
                            }
                            _loc_18 = null;
                        }
                        _loc_17 = null;
                    }
                    _loc_16.textfield.removeEventListener(TextEvent.LINK, this.doLink);
                    panel_chat.removeChild(_loc_16);
                    _loc_16.dispose();
                    _loc_16 = null;
                }
            }
            return _loc_9;
        }// end function

        public function showMsg(param1:Vector.<Array>) : void
        {
            var _loc_3:Array = null;
            var _loc_4:RichTextField = null;
            var _loc_5:Array = null;
            var _loc_6:Image = null;
            var _loc_7:String = null;
            var _loc_2:int = 0;
            for each (_loc_3 in param1)
            {
                
                if (_loc_3[3] == null)
                {
                    _loc_4 = new RichTextField();
                    _loc_4.textfield.mouseWheelEnabled = false;
                    _loc_4.setSize(410, 100);
                    _loc_4.type = RichTextField.DYNAMIC;
                    _loc_4.html = true;
                    _loc_4.textfield.selectable = false;
                    _loc_4.textfield.filters = [this.mFilter];
                    _loc_3.push(_loc_4);
                    _loc_5 = [];
                    if (_loc_3[0])
                    {
                        if (_loc_3[2] != "0_0")
                        {
                            _loc_6 = new Image("png.chatHead." + _loc_3[2]);
                            _loc_5.push({index:0, src:_loc_6});
                        }
                        _loc_3.push(_loc_5);
                        _loc_4.append(_loc_3[1], _loc_5);
                    }
                    else
                    {
                        this.checkSprites(_loc_3[1], _loc_5);
                        _loc_3[4] = _loc_5;
                        _loc_4.append(this.getMsg(_loc_3[2]), _loc_5, false, null, false);
                    }
                }
                else
                {
                    _loc_4 = _loc_3[3];
                }
                _loc_4.setSize(410, _loc_4.height);
                panel_chat.addChild(_loc_4);
                _loc_4.y = _loc_2;
                _loc_2 = _loc_2 + _loc_4.height;
                _loc_4.textfield.addEventListener(TextEvent.LINK, this.doLink);
            }
            panel_chat.scrollTo(0, _loc_2);
            return;
        }// end function

        public function setMsg(param1:Object) : void
        {
            var _loc_2:String = null;
            var _loc_3:Vector.<Array> = null;
            var _loc_4:Vector.<Array> = null;
            var _loc_5:Array = null;
            var _loc_6:RichTextField = null;
            var _loc_7:Array = null;
            var _loc_8:Object = null;
            ta_announce.text = param1.notice;
            txt_updatetime.text = "";
            this.memberRefresh(param1);
            for (_loc_2 in this._msgDic)
            {
                
                if (int(_loc_2) != param1.unionId)
                {
                    _loc_4 = this._msgDic[_loc_2];
                    while (_loc_4.length > 0)
                    {
                        
                        _loc_5 = _loc_4.shift();
                        _loc_6 = _loc_5[3];
                        if (_loc_6 != null)
                        {
                            _loc_7 = _loc_5[4];
                            if (_loc_7 != null)
                            {
                                while (_loc_7.length > 0)
                                {
                                    
                                    _loc_8 = _loc_7.shift();
                                    if (_loc_8.parent)
                                    {
                                        _loc_8.parent.removeChild(_loc_8);
                                    }
                                    if (_loc_8 is Clip)
                                    {
                                        _loc_8.stop();
                                    }
                                    _loc_8 = null;
                                }
                                _loc_7 = null;
                            }
                            _loc_6.textfield.removeEventListener(TextEvent.LINK, this.doLink);
                            panel_chat.removeChild(_loc_6);
                            _loc_6.dispose();
                            _loc_6 = null;
                        }
                    }
                    delete this._msgDic[_loc_2];
                }
            }
            _loc_3 = this._msgDic[param1.unionId];
            this.showMsg(_loc_3);
            return;
        }// end function

        public function memberRefresh(param1:Object) : void
        {
            var _loc_2:* = param1.memberList;
            var _loc_3:* = _loc_2 as Array;
            var _loc_4:* = _loc_3.length;
            var _loc_5:* = UnionUtil.memberShort(_loc_3);
            list_chater.array = _loc_5.members;
            list_chater.renderHandler = new Handler(this.chaterHandler);
            txt_members.text = "<b>行会成员</b>(" + _loc_5.online + "/" + _loc_4 + ")";
            this.selfMsg = _loc_5.self;
            return;
        }// end function

        private function chaterHandler(param1:Component, param2:int) : void
        {
            var _loc_3:Object = null;
            var _loc_4:Image = null;
            var _loc_5:Image = null;
            var _loc_6:int = 0;
            var _loc_7:Label = null;
            var _loc_8:int = 0;
            var _loc_9:String = null;
            if (param2 < list_chater.length)
            {
                _loc_3 = list_chater.array[param2];
                _loc_4 = param1.getChildByName("img_head") as Image;
                _loc_4.url = "png.chatHead." + _loc_3.career + "_" + _loc_3.sex;
                _loc_5 = param1.getChildByName("img_vip") as Image;
                _loc_6 = SocialUtil.checkVipLevel(_loc_3.vip, _loc_3.viptime, _loc_3.viplevel);
                if (_loc_6 > 0)
                {
                    _loc_5.url = "png.social." + _loc_6;
                }
                _loc_5.visible = _loc_6 >= 1;
                _loc_7 = param1.getChildByName("txt_name") as Label;
                _loc_8 = 11704940;
                _loc_9 = "";
                switch(_loc_3.title)
                {
                    case 15:
                    {
                        _loc_9 = "[会长]";
                        _loc_8 = 16763904;
                        break;
                    }
                    case 10:
                    {
                        _loc_9 = "[副会长]";
                        _loc_8 = 11705070;
                        break;
                    }
                    case 5:
                    {
                        _loc_9 = "[精英]";
                        _loc_8 = 45296;
                        break;
                    }
                    default:
                    {
                        break;
                    }
                }
                _loc_7.text = _loc_3.name + _loc_9;
                _loc_7.color = _loc_8;
                param1.disabled = !Boolean(_loc_3.online);
                param1.mouseEnabled = true;
                param1.removeEventListener(MouseEvent.CLICK, this.doListClick);
                if (_loc_3.name != UserData.getUserData("name"))
                {
                    param1.addEventListener(MouseEvent.CLICK, this.doListClick);
                }
            }
            return;
        }// end function

        protected function doListClick(event:MouseEvent) : void
        {
            var _loc_2:* = event.currentTarget as Box;
            this._menuGame.visible = true;
            this._menuGame.x = mouseX;
            this._menuGame.y = mouseY;
            this._menuGame.setMenu(_loc_2.dataSource);
            return;
        }// end function

        protected function fouseNone(event:MouseEvent) : void
        {
            GlobalLayer.instance.root.focus = null;
            this._menuGame.visible = false;
            return;
        }// end function

        protected function doStop(event:MouseEvent) : void
        {
            if (this.selfMsg.title < 10)
            {
                GlobalLayer.instance.root.focus = null;
                return;
            }
            event.stopPropagation();
            return;
        }// end function

        protected function fouseOut(event:FocusEvent) : void
        {
            img_announce.visible = false;
            if (this.selfMsg.title < 10)
            {
                WarningManager.show(65);
                return;
            }
            var _loc_2:* = ModelProxy.getValue("data", "configs1.banednames");
            UnionSender._24changeNotice(_loc_2.replaceAll(ta_announce.text));
            return;
        }// end function

        protected function fouseIn(event:FocusEvent) : void
        {
            img_announce.visible = true;
            this._menuGame.visible = false;
            return;
        }// end function

        protected function checkCloseTipHandler(event:MouseEvent) : void
        {
            if (this._ShowingTip)
            {
                this._ShowingTip = false;
                GlobalLayer.instance.root.removeEventListener(MouseEvent.CLICK, this.checkCloseTipHandler);
                ModelProxy.change("tips", "state", "close");
            }
            return;
        }// end function

        private function getTitle(param1:ChatVO) : String
        {
            var _loc_3:Object = null;
            var _loc_4:Object = null;
            var _loc_5:Object = null;
            var _loc_6:Object = null;
            var _loc_7:Object = null;
            var _loc_2:String = "";
            if (param1.isGm == "gm")
            {
                return "<font color=\'#dec026\'><b>【GM】</b></font>";
            }
            if (param1.Type == ChatCMD.ChannelUnion)
            {
                _loc_3 = ModelProxy.getValue("union", "unionInfo");
                if (_loc_3)
                {
                    _loc_4 = _loc_3.members.memberList;
                    for each (_loc_5 in _loc_4)
                    {
                        
                        if (_loc_5.rid == param1.RoleID)
                        {
                            if (_loc_5.title > 0)
                            {
                                _loc_2 = "<font color=\'{0}\'>{1}</font>";
                                _loc_2 = StringUtil.substitute(_loc_2, "#4fa7db", "【" + (_loc_5.title == 5 ? ("精英") : (_loc_5.title == 10 ? ("副会长") : ("会长"))) + "】");
                                return _loc_2;
                            }
                            break;
                        }
                    }
                }
            }
            if (param1.title >= 1000)
            {
                _loc_2 = "<font color=\'{0}\'>{1}</font>";
                _loc_6 = ConfigDictionary.data.title;
                _loc_7 = _loc_6[param1.title];
                switch(int(_loc_7.type))
                {
                    case 0:
                    {
                        _loc_2 = StringUtil.substitute(_loc_2, "#cf6cec", "【" + _loc_7.name + "】");
                        break;
                    }
                    case 1:
                    {
                        _loc_2 = StringUtil.substitute(_loc_2, "#d8a25c", "【" + _loc_7.name + "】");
                        break;
                    }
                    default:
                    {
                        _loc_2 = StringUtil.substitute(_loc_2, "#cf6cec", "【" + _loc_7.name + "】");
                        break;
                        break;
                    }
                }
            }
            return _loc_2;
        }// end function

        private function checkSprites(param1:String, param2:Array) : void
        {
            var _loc_13:String = null;
            var _loc_14:int = 0;
            var _loc_15:Object = null;
            var _loc_16:Clip = null;
            var _loc_17:int = 0;
            var _loc_18:Object = null;
            var _loc_19:Clip = null;
            var _loc_20:Boolean = false;
            var _loc_3:* = ModelProxy.getValue("data", "chatTrie");
            var _loc_4:* = param1.length;
            var _loc_5:String = "";
            var _loc_6:* = _loc_3.getRoot();
            var _loc_7:* = ConfigDictionary.data.face;
            var _loc_8:int = 0;
            var _loc_9:Boolean = false;
            var _loc_10:Boolean = false;
            var _loc_11:Boolean = true;
            var _loc_12:int = 0;
            while (_loc_12 < _loc_4)
            {
                
                _loc_13 = param1.charAt(_loc_12);
                if (this.isChecking)
                {
                    if (_loc_6[_loc_13])
                    {
                        _loc_6 = _loc_6[_loc_13];
                        _loc_5 = _loc_5 + _loc_13;
                        if (_loc_12 == (_loc_4 - 1))
                        {
                            if (_loc_6[""])
                            {
                                var _loc_21:Boolean = false;
                                _loc_11 = false;
                                var _loc_21:* = _loc_21;
                                _loc_10 = _loc_21;
                                var _loc_21:* = _loc_21;
                                _loc_9 = _loc_21;
                                this.isChecking = _loc_21;
                                _loc_6 = _loc_3.getRoot();
                                _loc_8++;
                                _loc_14 = 0;
                                for each (_loc_15 in _loc_7)
                                {
                                    
                                    if (_loc_15.protocol == _loc_5)
                                    {
                                        _loc_14 = _loc_15.times;
                                        break;
                                    }
                                }
                                _loc_16 = new Clip("png.common." + _loc_5.substr(1), _loc_14, 1);
                                _loc_16.autoPlay = true;
                                _loc_16.interval = 900 / _loc_14 + 100;
                                param2.push({index:_loc_8, src:_loc_16});
                                _loc_5 = "";
                            }
                        }
                    }
                    else if (_loc_6[""])
                    {
                        _loc_6 = _loc_3.getRoot();
                        _loc_17 = 0;
                        for each (_loc_18 in _loc_7)
                        {
                            
                            if (_loc_18.protocol == _loc_5)
                            {
                                _loc_17 = _loc_18.times;
                                break;
                            }
                        }
                        _loc_19 = new Clip("png.common." + _loc_5.substr(1), _loc_17, 1);
                        _loc_20 = _loc_5.length - _loc_12 != 0;
                        _loc_19.autoPlay = true;
                        _loc_19.interval = 900 / _loc_17 + 60;
                        _loc_5 = "";
                        if (_loc_6[_loc_13])
                        {
                            if (!_loc_9)
                            {
                                if (!_loc_10)
                                {
                                    if (_loc_20)
                                    {
                                        if (!_loc_11)
                                        {
                                            _loc_8++;
                                        }
                                    }
                                }
                            }
                            var _loc_21:Boolean = false;
                            _loc_10 = false;
                            _loc_11 = _loc_21;
                            var _loc_21:Boolean = true;
                            _loc_9 = true;
                            this.isChecking = _loc_21;
                            _loc_6 = _loc_6[_loc_13];
                            _loc_5 = _loc_5 + _loc_13;
                            param2.push({index:_loc_8, src:_loc_19});
                        }
                        else
                        {
                            param2.push({index:_loc_8, src:_loc_19});
                            this.isChecking = false;
                            _loc_9 = false;
                            _loc_8++;
                            _loc_10 = true;
                            _loc_11 = false;
                        }
                    }
                    else
                    {
                        _loc_6 = _loc_3.getRoot();
                        if (_loc_6[_loc_13])
                        {
                            this.isChecking = true;
                            _loc_6 = _loc_6[_loc_13];
                            _loc_8 = _loc_8 + _loc_5.length;
                            _loc_5 = "";
                            _loc_5 = _loc_5 + _loc_13;
                        }
                        else
                        {
                            var _loc_21:Boolean = false;
                            _loc_9 = false;
                            this.isChecking = _loc_21;
                            _loc_5 = _loc_5 + _loc_13;
                            _loc_8 = _loc_8 + _loc_5.length;
                            _loc_5 = "";
                        }
                    }
                }
                else if (_loc_6[_loc_13])
                {
                    this.isChecking = true;
                    _loc_6 = _loc_6[_loc_13];
                    _loc_5 = _loc_5 + _loc_13;
                }
                else
                {
                    _loc_8++;
                }
                _loc_12++;
            }
            return;
        }// end function

        private function getMsg(param1:String) : String
        {
            var _loc_8:String = null;
            var _loc_2:* = ModelProxy.getValue("data", "chatTrie");
            var _loc_3:* = param1.length;
            var _loc_4:String = "";
            var _loc_5:String = "";
            var _loc_6:* = _loc_2.getRoot();
            var _loc_7:int = 0;
            while (_loc_7 < _loc_3)
            {
                
                _loc_8 = param1.charAt(_loc_7);
                if (this.isChecking)
                {
                    if (_loc_6[_loc_8])
                    {
                        _loc_6 = _loc_6[_loc_8];
                        _loc_5 = _loc_5 + _loc_8;
                    }
                    else if (_loc_6[""])
                    {
                        _loc_6 = _loc_2.getRoot();
                        _loc_5 = "";
                        if (_loc_6[_loc_8])
                        {
                            this.isChecking = true;
                            _loc_6 = _loc_6[_loc_8];
                            _loc_5 = _loc_5 + _loc_8;
                        }
                        else
                        {
                            this.isChecking = false;
                            _loc_4 = _loc_4 + _loc_8;
                        }
                    }
                    else
                    {
                        _loc_6 = _loc_2.getRoot();
                        if (_loc_6[_loc_8])
                        {
                            this.isChecking = true;
                            _loc_6 = _loc_6[_loc_8];
                            _loc_4 = _loc_4 + _loc_5;
                            _loc_5 = "";
                            _loc_5 = _loc_5 + _loc_8;
                        }
                        else
                        {
                            this.isChecking = false;
                            _loc_5 = _loc_5 + _loc_8;
                            _loc_4 = _loc_4 + _loc_5;
                            _loc_5 = "";
                        }
                    }
                }
                else if (_loc_6[_loc_8])
                {
                    this.isChecking = true;
                    _loc_6 = _loc_6[_loc_8];
                    _loc_5 = _loc_5 + _loc_8;
                }
                else
                {
                    _loc_4 = _loc_4 + _loc_8;
                }
                _loc_7++;
            }
            return _loc_4;
        }// end function

        protected function doLink(event:TextEvent) : void
        {
            var links:Array;
            var p:Point;
            var fun:Function;
            var lv:int;
            var rein:int;
            var data:Object;
            var itemInfo:Object;
            var task1:Object;
            var arr:Array;
            var e:* = event;
            e.stopPropagation();
            links = e.text.split(",");
            if (links.length > 0)
            {
                p = new Point(GlobalLayer.instance.root.mouseX, GlobalLayer.instance.root.mouseY);
                switch(links[0])
                {
                    case "jsfunc":
                    {
                        ExternalInterface.call(links[1]);
                        break;
                    }
                    case "item":
                    {
                        if (this._ShowingTip)
                        {
                            this._ShowingTip = false;
                            GlobalLayer.instance.root.removeEventListener(MouseEvent.CLICK, this.checkCloseTipHandler);
                            ModelProxy.change("tips", "state", "close");
                        }
                        if (links[1] == 2)
                        {
                            p.y = p.y - 200;
                            itemInfo = ConfigDictionary.data.item[links[2]];
                            if (itemInfo.itemtype == 1)
                            {
                                ModelProxy.change("tips", "arm", {data:itemInfo, p:p});
                            }
                            else
                            {
                                ModelProxy.change("tips", "tool", {data:itemInfo, p:p});
                            }
                        }
                        else
                        {
                            Server.instance.send(110, 9, links[2], 0, ConnectType.SYSTEM);
                        }
                        this._ShowingTip = true;
                        fun = function () : void
            {
                if (_timeID > 0)
                {
                    clearTimeout(_timeID);
                    _timeID = 0;
                }
                GlobalLayer.instance.root.addEventListener(MouseEvent.CLICK, checkCloseTipHandler);
                return;
            }// end function
            ;
                        this._timeID = setTimeout(fun, 100);
                        break;
                    }
                    case "pos":
                    {
                        if (links[3] < 10000)
                        {
                            ModelProxy.change("zone", "autoMove", {x:links[1], y:links[2], tostageid:links[3], onhorse:true});
                        }
                        else
                        {
                            ModelProxy.change("movetips", "error", "目标为不可寻路到达的目的地，不能前往！");
                        }
                        break;
                    }
                    case "transfer":
                    {
                        break;
                    }
                    case "stallage":
                    {
                        ModelProxy.change("plugin", "sendSysMsg", {name:"stallage", param:links[1], cmd:8});
                        break;
                    }
                    case "recharge":
                    {
                        if (Config.gameParams.oper == "qq")
                        {
                            ModelProxy.change("plugin", "open", {target:"qqchongzhi"});
                        }
                        else
                        {
                            if (!ItemUilt.canpay)
                            {
                                ModelProxy.change("movetips", "error", "功能尚未开放，敬请期待");
                                return;
                            }
                            ExternalInterface.call("topay");
                        }
                        break;
                    }
                    case "plugin":
                    {
                        lv = UserData.getUserData("level");
                        rein = ModelProxy.getValue("data", "user.rein");
                        if (links[1] == "qianghua")
                        {
                            if (lv < 50)
                            {
                                ItemUilt.ErrortipsForLevel(50);
                                return;
                            }
                        }
                        if (links[1] == "juezhan")
                        {
                            if (links[2] == 3)
                            {
                                task1 = UserData.getData(UserDataType.Task);
                                if (task1["tid_189"] && task1["tid_189"].state == 4)
                                {
                                }
                                else
                                {
                                    ItemUilt.ErrortipsForLevel(0);
                                    return;
                                }
                            }
                        }
                        data = links[2];
                        if (links[1] == "kaifuhd")
                        {
                            arr = String(data).split("#");
                            data = new Object();
                            data.yeqian = arr[0];
                            if (arr.length > 1)
                            {
                                data.id = arr[1];
                            }
                        }
                        ModelProxy.change("plugin", "change", {target:links[1], point:p, data:data});
                        break;
                    }
                    case "multiinstance":
                    {
                        if (ModelProxy.getValue("data", "hasMultiGroup"))
                        {
                            ModelProxy.change("movetips", "error", "您已有队伍");
                        }
                        else
                        {
                            ModelProxy.change("data", "isMultiInstanceJoinning", true);
                        }
                        break;
                    }
                    case "unionEmsTrans":
                    {
                        UnionSender._62unionEmsJoin();
                        break;
                    }
                    default:
                    {
                        break;
                    }
                }
            }
            return;
        }// end function

    }
}
